package src;
import java.util.*;
public class Main {
    static List<List<Integer>> result=new ArrayList<List<Integer>>();
    static boolean[]is;
    public static void main(String[] args) {


    }
    static List<List<Integer>> permute(int[] nums) {
        is=new boolean[nums.length];
        dfs(nums,new ArrayList<>());
        return result;
    }
    static void dfs(int[]nums,List<Integer>list){
        if(list.size()==nums.length){
            System.out.println(list);
            result.add(list);
            return;
        }
        for (int i = 0; i < nums.length; i++) {
            if(is[i]){
                continue;
            }
            list.add(nums[i]);
            is[i]=true;
            System.out.println("之前"+list);
            dfs(nums,list);
            list.remove(list.size()-1);
            is[i]=false;
            System.out.println("之后"+list);
        }
    }
}